package com.daervin.svc.iml;

import com.daervin.svc.IMappingService;
import com.daervin.svc.dal.IDarlingDataDao;
import com.daervin.svc.dal.model.DarlingData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * Created by daervin on 2021/4/1
 */
@Service
public class MappingServiceImpl implements IMappingService {
    @Autowired
    private IDarlingDataDao dataDao;

    @Override
    public String mapping(String key) {
        if (StringUtils.isEmpty(key)) {
            return null;
        }

        DarlingData darlingData = dataDao.selectByKey(key);
        if (darlingData == null) {
            return null;
        }
        return darlingData.getOriginalUrl();
    }
}
